package com.link.base.base.product.service;

import com.link.base.base.product.dao.mybatis.mapper.ProdRcmdMapper;
import com.link.base.base.product.model.ProdRcmd;
import com.link.base.base.enterprise.dao.mybatis.mapper.EnterpriseMapper;
import com.link.base.base.enterprise.model.Enterprise;
import com.link.core.basic.dao.mapper.BasicMapper;
import com.link.core.basic.service.BasicServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author unknown
 * @date unknown
 */
@Service
public class ProdRcmdServiceImpl extends BasicServiceImpl<ProdRcmd> implements ProdRcmdService {

    @Resource
    private ProdRcmdMapper prodRcmdMapper;

    @Resource
    private EnterpriseMapper enterpriseMapper;

    @Override
    public BasicMapper<ProdRcmd> getBasicMapper() {
        return prodRcmdMapper;
    }

    /**
     * 该方法为app中迁移过来的方法
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @Override
    public List<ProdRcmd> queryAllActive(ProdRcmd entity) throws Exception {

        Enterprise param = new Enterprise();
        param.setCode(entity.getCorpid());
        param.setPageFlag(false);
        List<Enterprise> enterList = enterpriseMapper.queryByExamplePage(param);
        if (enterList.size() > 0) {
            entity.setIsMultiPriceList(enterList.get(0).getIsMultiPriceList());
        }
        return prodRcmdMapper.queryAllActive(entity);
    }
}
